package kpi.java_training.domain.questions;

/**
 * Created by Alex Kebkalo (kebka@mail.ru) on 12.03.14.
 */
public class QuestionsFactory {
    public static Question getQuestion(QuestionData questionData) {
        switch (questionData.type) {
            case "one": return new OneFromManyAnswersQuestion(questionData.textOfQuestion, questionData.answerVariants,
                    questionData.correctAnswer, Integer.parseInt(questionData.complexity));

            case "multi": return new MultiAnswersQuestion(questionData.textOfQuestion, questionData.answerVariants,
                    questionData.correctAnswer, Integer.parseInt(questionData.complexity));

            case "yes-no": return new YesNoQuestion(questionData.textOfQuestion, questionData.answerVariants,
                    questionData.correctAnswer, Integer.parseInt(questionData.complexity));

            case "text": return new TextAnswerQuestion(questionData.textOfQuestion, questionData.answerVariants,
                    questionData.correctAnswer, Integer.parseInt(questionData.complexity));

            default: return null;
        }
    }
}
